package com.sand.controller;

import com.sand.dto.Select.UserSelect;
import com.sand.dto.supplier.AddSupplier;
import com.sand.dto.supplier.SupplierDto;
import com.sand.entity.user.supplier;
import com.sand.result.ResponseResult;
import com.sand.service.SupplierService;
import com.sand.text.CloudText;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;


    /**
     * 新增供货商(完成)
     */
    @PostMapping("/add")
    public ResponseResult<String> add(@RequestBody AddSupplier addSupplier){

        String i = supplierService.add(addSupplier);

        return new ResponseResult<String>().okResult(i);
    }


    /**
     * 查询供货商(完成)
     */
    @PostMapping("/select")
    public ResponseResult<SupplierDto> select(@RequestBody UserSelect userSelect){

        SupplierDto supplierDto = supplierService.select(userSelect);

        return new ResponseResult<SupplierDto>().okResult(supplierDto);
    }

    /**
     * 查询所有供货商(完成)
     */
    @PostMapping("/list")
    public ResponseResult<List<SupplierDto>> listAll(){
         List<SupplierDto> list = supplierService.listAll();
         return new ResponseResult<List<SupplierDto>>().ok(list);
    }


}
